package com.hl.toolkit.admin.system.security;

import com.tycoin.system.slaveentity.User;
import org.apache.shiro.UnavailableSecurityManagerException;
import org.apache.shiro.subject.Subject;


public class SecurityUtils {
    /**
     * 获取当前用户
     *
     * @return
     */
    public static User getUser() {
        try {
            Subject subject = org.apache.shiro.SecurityUtils.getSubject();
            User user = (User) subject.getPrincipal();
            return user;
        } catch (UnavailableSecurityManagerException e) {
            return null;
        } catch (Exception e) {
            return null;
        }
    }

}
